package com.bojiu.lawsearch.lawsearch.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

/**
 * @author: afdiao
 * @Date：2020/3/17 14:22
 * @Description:
 */
@Component
@Slf4j
public class MailHandler {
    @Autowired
    JavaMailSender javaMailSender;

    public void sendMail(String text, String email) {
        SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
        //设置主题
        simpleMailMessage.setSubject("法律规范提问通知");
        //设置正文
        simpleMailMessage.setText(text);
        //邮件发送方
        simpleMailMessage.setFrom("2539236780@qq.com");
        //邮件接收方
        simpleMailMessage.setTo("1583033584@qq.com");
//        simpleMailMessage.setTo(email);
        javaMailSender.send(simpleMailMessage);
    }
}
